<template>
  <div class="tx">
    <el-dialog
      :visible.sync="dialogVisible"
      width="30%">
      <div class="tx-header">
        <span>{{$parent.clickType == 0?'新增基本信息字段':'编辑基本信息字段'}}</span>
      </div>
      <ul class="tx-form">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
          <el-form-item label="字段名称" prop="fieldName">
            <el-input v-model="ruleForm.fieldName" placeholder="请输入字段名"></el-input>
          </el-form-item>
          <el-form-item label="字段类型" prop="fieldType">
            <el-select v-model="ruleForm.fieldType" placeholder="请选择字段类型">
              <el-option label="文本" value="geren"></el-option>
              <el-option label="js" value="gongsi"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="提示文字" prop="fieldTexe">
            <el-select v-model="ruleForm.dimissionCause" placeholder="请输入字段备注，以便员工理解如何录入">
              <el-option label="如果办理离职" value="geren"></el-option>
              <el-option label="如果办理入职" value="gongsi"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="要求员工必填" prop="isRequired">
            <el-radio v-model="ruleForm.isRequired" label="1">必填</el-radio>
            <el-radio v-model="ruleForm.isRequired" label="2">选填</el-radio>
          </el-form-item>
          <el-form-item label="在入职登记表中" prop="isRegister">
            <el-radio v-model="ruleForm.isRegister" label="1">显示</el-radio>
            <el-radio v-model="ruleForm.isRegister" label="2">隐藏</el-radio>
          </el-form-item>
          <el-form-item label="在个人档案中" prop="isExistFile">
            <el-radio v-model="ruleForm.isExistFile" label="1">对员工可见</el-radio>
            <el-radio v-model="ruleForm.isExistFile" label="2">对员工不可见</el-radio>
            <br/>
            <el-radio v-model="ruleForm.isExistFile" label="3">员工可修改</el-radio>
            <el-radio v-model="ruleForm.isExistFile" label="4">员工不可修改</el-radio>
          </el-form-item>
        </el-form>
      </ul>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" class="red-b" @click="submit('ruleForm')">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props:['dialogVisible','changePopping','isForbiddenInput'],
  data (){
    return {
      ruleForm: {
        fieldName: '',//姓名
        fieldType:'',//字段类型
        fieldTexe:'',//提示文字
        isRequired:'1',//是否必填
        isRegister:'1',//是否登记
        isExistFile:'1',//是否存在个人档案中

      },
      rules:{
        fieldName: [
          { required: true, message: '请输入字段名称', trigger: 'bulr' },
        ],
        fieldType: [
          { required: true, message: '请输入字段类型', trigger: 'change' },
        ],
      },
    }
  },
  methods:{
    //提交按钮
    submit(formName){
      this.$refs[formName].validate((valid) => {
          if (valid) {
            let {name,dimissionTime,dimissionCause,dimissionRemark} = {...this.ruleForm}
            this.changePopping()
          } else {
            this.$message.error('请按要求填写')
            return false;
          }
        });
    },
    //取消按钮
    cancel(){
      console.log(this.$parent.clickType,'this1指向')
      this.$parent.dialogVisible = false
      // this.changePopping()
    },
  },
}
</script>

<style scoped>
  .tx /deep/ .el-dialog__header{
    display: none;
  }
  .tx /deep/ .el-dialog__wrapper{
    border-radius: 10px;
  }
  .tx-header{
    height: 42px;
    line-height: 42px;
    background: #EEEEEE;
    
    border-radius: 10px;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    text-align: center;
    margin-bottom: 50px;  
  }
  .tx /deep/ .el-dialog__body{
    padding: 0;
  }
  .tx-form{
    padding: 0 70px 0 70px;
  }
  .tx /deep/ .el-date-editor.el-input, .el-date-editor.el-input__inner{
    width: 100%;
  }
  .tx /deep/ .el-select{
    width: 100%;
  }
  .tx /deep/ .el-select-dropdown__item.hover{
    background: #ff0000;
    color:#fff;
  }
  .tx /deep/ .el-dialog__footer{
    text-align: center;
    margin-bottom: 20px;
  }
  .tx /deep/ .el-button--medium{
    width: 23%;
    height: 38px;
    border-radius: 19px;
  }
  .tx /deep/ .el-button--primary{
    margin-right: 20px;
    border: none;
  }
  .tx /deep/ .el-radio__input.is-checked .el-radio__inner{
    border-color: #DD0505;
    background: #fff;
  }
  .tx /deep/ .el-radio__inner::after{
    background:#DD0505;
    width: 6px;
    height: 6px;
  }
  .tx /deep/  .el-radio__input.is-checked + .el-radio__label{
    color:#666;
  }
</style>